package com.xq.tmall.service;

import com.alibaba.fastjson.JSONObject;
import com.xq.tmall.agu.ferign.JisiluSpilder;
import com.xq.tmall.dao.StockDao;
import com.xq.tmall.entity.Stock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;

/**
 * Stock service
 *
 * @author chenguoxiang
 * @create 2018-03-27 10:27
 **/
@Service
public class StockService {

    @Resource
    private StockDao stockDao;

    public List<Stock> getSHStockCodes() {
        Map<String,Object> params = new HashMap<>();
        params.put("type","sh");
        return stockDao.findStockInfo(params);
    }

    public List<Stock> getSZStockCodes() {
        Map<String,Object> params = new HashMap<>();
        params.put("type","sz");
        return stockDao.findStockInfo(params);
    }

    public List<Stock> getCYStockCodes() {
        Map<String,Object> params = new HashMap<>();
        params.put("type","cy");
        return stockDao.findStockInfo(params);
    }

    /**
     * 获取所有股票代码
     * @return
     */
    public List<Stock> findAllStockInfo() {
        Map<String,Object> params = new HashMap<>();
        return stockDao.findStockInfo(params);
    }

    public int updateByPrimaryKeySelective(Stock stock){
        return stockDao.updateByPrimaryKeySelective(stock);
    }

    /**
     * @param stockList
     * @return
     */
    public int batchUpdate(List<Stock> stockList){

        return stockDao.batchUpdate(stockList);
    }

    /**
     * @param stockList
     * @return
     */
    public int batchUpdateVolume(List<Stock> stockList){

        return stockDao.batchUpdateVolume(stockList);
    }


    /**
     * 判断今天是否执行股票更新
     * @return
     */
    public int getTodayCount() {
        return stockDao.getTodayCount();
    }

}
